package com.ruibang.glass.material.controller;

import com.ruibang.glass.material.domain.req.*;
import com.ruibang.glass.material.entity.MaterialContentLot;
import com.ruibang.glass.material.service.MaterialContentLotService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import com.teaming.cloud.framework2.common.pojo.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * <p>
 * A型架和水平托盘容器绑定的批次号信息 前端控制器
 * </p>
 *
 * @author wujie
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/api/material/content/lot")
@Api(value="A型架和水平托盘容器绑定的批次号信息控制层",tags={"A型架和水平托盘容器绑定的批次号信息操作接口"})
public class MaterialContentLotController {

    
    @Autowired
    private MaterialContentLotService materialContentLotService;

    
    /**
    * 通过id查询
    */
    @GetMapping("/getById/{id}")
    @ApiOperation(value="获取A型架和水平托盘容器绑定的批次号信息",notes="获取A型架和水平托盘容器绑定的批次号信息")
    public ResultBody getById(@PathVariable(value = "id") String id){
        return ResultBody.success(materialContentLotService.getById(id));
    }

    /**
    * 新增
    */
    @PostMapping("/save")
    @ApiOperation(value="新增A型架和水平托盘容器绑定的批次号信息",notes="新增A型架和水平托盘容器绑定的批次号信息")
    public ResultBody save(@RequestBody MaterialContentLot materialContentLot){
        materialContentLotService.save(materialContentLot);
        return ResultBody.success();
    }

    /**
    * 通过id删除
    */
    @GetMapping("/deleteById/{id}")
    @ApiOperation(value="通过ID删除A型架和水平托盘容器绑定的批次号信息",notes="通过ID删除A型架和水平托盘容器绑定的批次号信息")
    public ResultBody delete(@PathVariable(value = "id") String ids){
        String[] idsStrs = ids.split(",");
        for (String id:idsStrs){
            materialContentLotService.removeById(Integer.parseInt(id));
        }
        return ResultBody.success();
    }

    /**
    * 修改
    */
    @PostMapping("/update")
    @ApiOperation(value="修改A型架和水平托盘容器绑定的批次号信息",notes="修改A型架和水平托盘容器绑定的批次号信息")
    public ResultBody updateById(@RequestBody MaterialContentLot materialContentLot){
        materialContentLotService.updateById(materialContentLot);
        return ResultBody.success();
    }


    /**
    * 分页查询
    */
    @PostMapping("/page")
    @ApiOperation(value="分页列表查询A型架和水平托盘容器绑定的批次号信息",notes="分页列表查询A型架和水平托盘容器绑定的批次号信息")
    public ResultBody page(@RequestBody PageRequest<MaterialContentLotReq> pageParam){
        return ResultBody.success(materialContentLotService.queryPage(pageParam));
    }

    /**
     * 分页查询
     */
    @PostMapping("/queryAppPage")
    @ApiOperation(value="PDA查询批次信息",notes="PDA查询批次信息")
    public ResultBody queryAppPage(@RequestBody PageRequest<MaterialContentLotReq> pageParam){
        return ResultBody.success(materialContentLotService.queryAppPage(pageParam));
    }

    @GetMapping("/getContentDetail/{lotId}")
    @ApiOperation(value="PDA查询A型架信息",notes="PDA查询A型架信息")
    public ResultBody getContentDetail(@PathVariable("lotId") String lotId){
        return ResultBody.success(materialContentLotService.getContentDetail(lotId));
    }

    @PostMapping("/getGlassBindData")
    @ApiOperation(value="PDA查询批次详情信息",notes="PDA查询批次详情信息")
    public ResultBody getGlassBindData(@RequestBody @Valid GlassBindReq glassBindReq){
        return ResultBody.success(materialContentLotService.getGlassBindData(glassBindReq));
    }

    @PostMapping("/unbind")
    @ApiOperation(value="解绑玻璃",notes="解绑玻璃")
    public ResultBody unbind(@RequestBody @Valid UnbindReq unbindReq){
        materialContentLotService.unbind(unbindReq);
        return ResultBody.success();
    }

    @PostMapping("/applyCheck")
    @ApiOperation(value="申请质检",notes="申请质检")
    public ResultBody applyCheck(@RequestBody @Valid QualityCheckReq checkReq){
        materialContentLotService.applyCheck(checkReq);
        return ResultBody.success();
    }
    @PostMapping("/checkQuality")
    @ApiOperation(value="质检",notes="质检")
    public ResultBody checkQuality(@RequestBody @Valid QualityCheckReq checkReq){
        materialContentLotService.checkQuality(checkReq);
        return ResultBody.success();
    }

    @PostMapping("/changeQuality")
    @ApiOperation(value="更改品质",notes="更改品质")
    public ResultBody changeQuality(@RequestBody @Valid QualityChangeReq changeReq){
        materialContentLotService.changeQuality(changeReq);
        return ResultBody.success();
    }

    @GetMapping("/applyWarehouse/{lotId}")
    @ApiOperation(value="申请入库",notes="申请入库")
    public ResultBody applyWarehouse(@PathVariable("lotId") String lotId){
        materialContentLotService.applyWarehouse(lotId);
        return ResultBody.success();
    }
}
